#include<bits/stdc++.h>
using namespace std;
struct node{
    double x,v,a;
};
struct node2{
    int l,r;
};
bool cmp2(node2 aa,node2 bb){
    return aa.l<=bb.l;
}
int n,m,t;
const int maxn=2e5+10;
node k[maxn];
int pos[maxn];
int check_[maxn];
bool vis[maxn];
int len,max_v;
node2 temp[maxn];
double work_(double lv,double rv,double a_){
    return (rv*rv-lv*lv)/(2*a_);
}
bool S[maxn];
vector<int > list_[maxn];
int name_[maxn];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t){
        t--;
        cin>>n>>m>>len>>max_v;
        for(int i=1;i<=n;i++){
            cin>>k[i].x>>k[i].v>>k[i].a;
        }
        memset(vis,false,sizeof(vis));
        for(int i=1;i<=m;i++){ cin>>pos[i]; vis[pos[i]]=true;}
        int cnt=0;
        for(int i=1;i<=n;i++){
                if(k[i].a==0){
                    if(k[i].v>max_v){
                        cnt++;
                        temp[cnt].l=k[i].x;
                        temp[cnt].r=len;
                    }
                    continue;
                }
                if(k[i].v<=max_v){
                    if(k[i].a>0){
                        //cnt++;
                        double xx=k[i].x+work_(k[i].v,max_v,k[i].a);
                        //cout<<work_(k[i].v,max_v,k[i].a)<<endl;
                        if(xx>=len) continue;

                        int op;
                        if(int(xx)==xx) op=xx;
                        else op=int(xx)+1;
                        bool flag=true;
                        for(int mm=op;mm<=len;mm++) if(vis[mm]){ flag=false;break;}
                        if(flag) continue;
                        cnt++;
                        temp[cnt].l=op;
                        temp[cnt].r=len;
                    }
                }
                else{
                    if(k[i].a<0){

                        double xx=k[i].x+work_(k[i].v,max_v,k[i].a);
                        //if(xx>=len) continue;
                        int op;
                        if(int(xx)==xx) op=xx;
                        else op=int(xx);
                        bool flag=true;
                        for(int mm=k[i].x;mm<=op;mm++) if(vis[mm]){ flag=false;break;}
                        if(flag) continue;
                        cnt++;
                        op=min(op,len);
                        temp[cnt].l=k[i].x;
                        temp[cnt].r=op-1;
                    }
                }
        }
        sort(temp+1,temp+cnt+1,cmp2);
        for(int i=1;i<=cnt;i++) name_[i]=temp[i].l;
        for(int i=1;i<=m;i++){
            int num=upper_bound(name_+1,name_+cnt+1,pos[i])-name_;
            for(int j=num;j>=1;j--){
                if(temp[j].l<=pos[i]&&pos[i]<=temp[j].r) list_[i].push_back(j);
            }
        }
        /*for(int i=1;i<=n;i++){
            cout<<list_[i].size()<<endl;
        }*/
        //sort(list_+1,list_+m+1,cmp2);
        int sum=0;
        int ans=0;
        memset(S,false,sizeof(S));
        while(sum<cnt){
            int max_=-1;
            int happy;
            for(int i=1;i<=m;i++){
                int c=0;
                int p=list_[i].size();
                for(int j=0;j<list_[i].size();j++){if(S[list_[i][j]]) c++;}
                //cout<<c<<endl;
                if(p-c>=max_){
                    happy=i;
                    max_=p-c;
                }
                //cout<<max_<<endl;
            }
            for(int i=0;i<list_[happy].size();i++){
                if(!S[list_[happy][i]]){
                    sum++;
                    S[list_[happy][i]]=true;
                }
            }
            //for(int i=1;i<=m;i++) cout<<S[i]<<" ";
            //cout<<endl;
            ans++;
            //cout<<ans<<endl;
        }
        for(int i=1;i<=cnt;i++)  list_[i].clear();
        cout<<cnt<<" "<<m-ans<<endl;
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
